package org.example.classtopia.Mapper;

import org.apache.ibatis.annotations.Select;
import org.example.classtopia.Model.Entity.User;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface UserMapper {
    void insertUser(User user);
    User FindByEmail(String email);
    void LoginUpdate(User user);
    User FindByEmailAndPassword(String email, String password);
    void CommonDataUpdate(User user);
    User FindCommonData(Long id);
    void PasswordUpdate(User user);
    void ResetPassword(User user);
    User FindDataByID(Integer id);
    void UpdateAvatar(String avatar, Long id);
    void UpdateUserStatus(Long id, Integer status);

    @Select("SELECT id FROM users WHERE status = 0")
    List<Long> selectAllUserIds();

    /**
     * 根据id查询用户全部信息
     * @param id 用户ID
     * @return User实体
     */
    @Select("SELECT * FROM users WHERE id = #{id} AND status = 0 LIMIT 1")
    User FindById(Long id);

    @org.apache.ibatis.annotations.Select("SELECT COUNT(*) FROM users")
    long countAllUsers();

    @Select("SELECT * FROM users WHERE id = #{id} AND status = 0 LIMIT 1")
    User findById(Long id);
}
